<template>
  <div class="columninone">
    <el-table :data="tableData">
      <el-table-column type="index" label="序号" width="50"> </el-table-column>
      <el-table-column
        prop="name"
        label="站点名称"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="deletedDate"
        label="删除时间"
        width="200"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="loginId"
        label="删除人员"
        width="200"
        align="center"
      >
      </el-table-column>
      <el-table-column prop="channelNum" label="栏目数" align="center">
      </el-table-column>
      <el-table-column prop="articleNum" label="文章数" align="center">
      </el-table-column>
      <el-table-column prop="templateNum" label="模板数" align="center">
      </el-table-column>
      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <el-button @click="handlePreview(scope.row)" type="text" size="small"
            >浏览</el-button
          >
          <el-button
            @click="handleRecy(scope.row)"
            type="text"
            size="small"
            v-hasPermi="['system:recycle:update']"
            >还原</el-button
          >
          <el-button
            @click="handleDel(scope.row)"
            type="text"
            size="small"
            v-hasPermi="['system:recycle:remove']"
            >彻底删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
//栏目接口调用,栏目删除调用
import {
  recycleSiteList,
  recycle_S,
  deleteForEver_S,
} from "@/api/content/recyclingStation";
import { makeSiteViewUrl } from "@/api/content/clounm";
//---------------------------
export default {
  props: {
    siteRow: Object,
  },
  data() {
    return {
      tableData: [],
    };
  },

  components: {},

  computed: {},
  watch: {
    // siteRow: {
    //   handler(val) {
    //     this.getList();
    //   },
    //   deep: true,
    //   immediate: true,
    // },
  },
  mounted() {
    //读取表格数据
    this.getList();
  },

  methods: {
    //浏览回收站栏目信息
    handlePreview(row) {
      makeSiteViewUrl({ siteAlias: row.alias }).then((res) => {
        let href = res.msg;
        window.open(href, "_blank");
      });
    },

    //还原回收站栏目信息
    handleRecy(row) {
      this.$confirm("此操作将还原该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          recycle_S({ siteId: row.siteId }).then((res) => {
            if (res.code == 200) {
              this.getList();
            }
          });
          this.msgSuccess("还原成功");
        })
        .catch(() => {
          this.msgSuccess("已取消还原");
        });
    },

    //删除回收站栏目信息
    handleDel(row) {
      this.$confirm("此操作将彻底删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteForEver_S({ siteId: row.siteId }).then((res) => {
            if (res.code == 200) {
              this.getList();
            }
          });
          this.msgSuccess("删除成功");
        })
        .catch(() => {
          this.msgSuccess("已取消删除");
        });
    },

    //读取回收站栏目信息
    getList() {
      recycleSiteList({
        siteId: this.siteRow?.siteId || this.CONSTANCE.siteId,
      }).then((res) => {
        this.tableData = res.data;
      });
    },
  },
};
</script>

<style scoped lang="scss">
.columninone {
  height: 100%;
  .el-table {
    width: 100%;
  }
}
</style>
